subroutine get_nstop(e,nh,r)
  use param
  use global
  use gi10
  implicit none
  real(dbl),intent(in) :: e
  integer,intent(in) :: nh
  real(dbl),intent(out) :: r
  real(dbl) :: dh,h1,h2,te,f,p1,p2,ir1,ir2
  integer :: i
  logical :: foo
  h1=0.5*e
  te=e
  dh=(te-h1)/real(nh)
  foo=.true.
  r=0
  do while(foo)
     h2=h1+dh
     if (h2.ge.te) then
        h2=te
        dh=te-h1
        foo=.false.
     end if
     f=0
     do i=1,ngi
        p1=0.5*(dh*qp(i)+h1+h2)
        p2=e-p1
        if (p2.le.0) cycle
        call kernel(e,p1,ir1)
        call kernel(e,p2,ir2)
        f=f+(ir1+ir2)*p2*qw(i)
     end do
     f=0.5*dh*f
     r=r+f
     h1=h2
  end do
  return
end subroutine get_nstop
